package com.wm.task.view;

import com.wm.task.dao.AdminDAO;
import com.wm.task.vo.User;

import java.util.List;

public class AdminView extends BaseView {
    private AdminDAO adminDAO = new AdminDAO();
    private List<User> userList;

    @Override
    protected void handleChoice(String choice) {
        switch (choice) {
            case "1":
                userManage();//用户管理
                break;
            case "2":
                movieManage();//电影管理
                break;
            case "3":
                scoreManage();//评分管理
                break;
        }

    }

    private void userManage() {
        userList = adminDAO.userList();
        for (User user : userList) {
            System.out.println(user.getId() + " " + user.getPhoneNum()
                    + " " + user.getPass() + user.getName()
                    + " " + user.getTime() + user.getSecretQuestion()
                    + " " + user.getSecretAnswer());
        }
        System.out.print("请输入要删除的用户ID:(选择 0 退出删除)");
        int id = sc.nextInt();
        if(id == 0){
            return;
        }
        adminDAO.userDelete(id);

    }

    private void movieManage() {

    }

    private void scoreManage() {

    }

    @Override
    protected String getTitle() {
        return "万码影评网(管理员)";
    }

    @Override
    protected String[] getMenus() {
        return new String[]{"用户管理", "电影管理", "评分管理", "退出"};
    }
}
